package com.demo.spark.sql;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SQLContext;

public class DataFrameCsv {
    public static void main(String[] args) {

        SparkConf sparkConf = new SparkConf().setMaster("local").setAppName("data frame ");
        JavaSparkContext sparkContext = new JavaSparkContext(sparkConf);
        sparkContext.setLogLevel("error");
        SQLContext sqlContext = new SQLContext(sparkContext);


        Dataset<Row> parquet = sqlContext.read().format("csv").load("./test/person.csv");
        parquet.show();

        parquet.createOrReplaceTempView("person");
        Dataset<Row> sql = sqlContext.sql("select _c0,_c1 from person");
        sql.show();
        
    }
}
